var util = require('../../utils/util.js');
var qcloud = require('../../vendor/wafer2-client-sdk/index')
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    winWidth: 0,
    winHeight: 0,
    currentTab: 0, // tab切换 
    isHiddenMes: true,
    assessInfo: {},//1全部
    safedInfo:{},
    avatarUrl: '/images/small_avatar.png',
    nickname:'',
    starImgList:[1,2,3,4,5],
    userInfo:'',
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this;
    util.post(app.api.myassess, { openid: app.globalData.openid}, function (res)     {
      console.log(res.data);
      that.setData({
        assessInfo: res.data,
      });
    });
    util.post(app.api.mysafed, { openid: app.globalData.openid }, function (res) {
      console.log(res.data);
      that.setData({
        safedInfo: res.data,
      });
    });
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          clientHeight: res.windowHeight
        });
      }
    });
    that.setData({
      avatarUrl: app.globalData.userInfo.avatarUrl != null ? app.globalData.userInfo.avatarUrl : '/images/small_avatar.png'
    });
    that.setData({
      userInfo: app.getUserInfo(),
    });
  },
 
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
   
  },

  //猎头详细信息
  hunterTap: function (event) {
    var id = event.currentTarget.dataset.id; // 当前id
    console.log("猎头详情id获取=" + id)
    // 切换页面
    wx.navigateTo({
      url: '../hunter-detail/hunter-detail?hunterid=' + id
    });
  },
  
  //滑动切换tab
  bindChangeTab: function (e) {
    
    this.setData({ currentTab: e.detail.current });

  },
  
  //点击tab切换
  swichNav: function (e) {
    var that = this ;
    if (this.data.currentTab === e.target.dataset.current) {
      return false;
    } else {
      this.setData({
        currentTab: e.target.dataset.current
      })
    }
  },
  safedTap: function (event){
    var safedId = event.currentTarget.dataset.id;
   wx.navigateTo({
     url: '../assess/assess?id='+safedId,
   })
  }
})